package com.lanou3g.Code0523.permission;

import javax.servlet.DispatcherType;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/5/23;
 * Otherwise, I don't know who created it either
 *
 * Filter 可以通过DispatcherType 来配置拦截方式
 * 有4种拦截方式比较常用
 * 1. REQUEST : 默认拦截方式,如果不写该项配置,则使用此拦截方式
 *      只会拦截请求,转发,包含都不再进行拦截
 * 2. FORWARD : 拦截请求转发
 * 3. INCLUDE : 拦截请求包含
 * 4. ERROR : 如果在jsp中配置了 errorPage,当出现异常时,
 *      进入errorPage之前,可以被该拦截器 拦截
 * 默认不写是 REQUEST,只要写了,无论写什么,都以写的为准
 * 即不再提供默认,如果还想拦截请求,则需要手动写上
 *
 */
// /my.do -> /user/shoppingCart.html
@WebFilter(filterName = "myFilter",urlPatterns = "/user/*",
dispatcherTypes = {DispatcherType.FORWARD,
        DispatcherType.REQUEST})
public class MyFilter extends BaseFilter {
    @Override
    public void doFilter(HttpServletRequest request,
                         HttpServletResponse response,
                         FilterChain chain) throws IOException, ServletException {

    }
}
